package org.example.juc.p07;

/**
 * @author lou ke
 * @since 2024/2/10 14:01
 */
public class CreateThread {

    public static void main(String[] args) {
        createRunnable();
        createThread();
        createFunctionRunnable();
    }

    public static void createRunnable() {
        // new Runnable 匿名内部类
        Thread thread = new Thread(new Runnable() {
            @Override
            public void run() {
                System.out.println("线程Runnable...");
            }
        });

        thread.start();
    }

    /**
     * lamdba表达式
     */
    public static void createFunctionRunnable() {
        Thread thread = new Thread(() -> {
            System.out.println("函数式方法，线程runnable...");
        });
        thread.start();
    }

    public static void createThread() {
        Thread thread = new Thread() {
            public void run() {
                System.out.println("线程Thread...");
            }
        };
        thread.start();
    }
}
